Hey there mkps.
This works great as an example how to go about an ordered list. as in, the order of the nodes clearly have parent paths predefined as well as children paths.
In my case, all I have is paths on points.
So for example.
pt0 PathAttrib = /obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal
pt1 PathAttrib = /obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6/unreal
I mean I guess I could do something where I go through these paths, and create an ordered list like you had, and then use that def you made above.
so for pt0 i would need to use the full path: /obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal
to create..
/obj/env_city_layout
/obj/env_city_layout/instances/
/obj/env_city_layout/instances/flatSlabs/
etc...
I did manage to create a script that gets close but it creates double objs/ (/obj/obj)
import hou
FullPath = ['/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal', '/obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6/unreal',
'/obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24/unreal','/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4/unreal',
'/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5/unreal']
for path in FullPath:
#print path
parent, name = path.split("/", 1)
for part in path:
pathSplit = path.split ("/")
#print pathSplit
indexToRemove = [0]
for index in sorted(indexToRemove, reverse=True):
del pathSplit[index]
#print pathSplit
for index in range (len(pathSplit)):
#print pathSplit[index]
# if index == 0:
#pathNew = str(pathSplit[0]) + "/" + str(pathSplit[1])
#indexToRemove = [0, 1]
#for index in sorted(indexToRemove, reverse=True):
#del pathSplit[index]
#pathSplit.insert(0, pathNew)
pathNew = str(pathSplit[0]) + "/" + str(pathSplit[index])
del pathSplit[0]
pathSplit.insert(0, pathNew)
print pathNew
this spits out:
>>> obj/obj
obj/obj/env_city_layout
obj/obj/env_city_layout/instances
obj/obj/env_city_layout/instances/flatSlabs
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal
obj/obj
obj/obj/env_city_layout
obj/obj/env_city_layout/instances
obj/obj/env_city_layout/instances/largeTower
obj/obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6
obj/obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6/unreal
obj/obj
obj/obj/env_city_layout
obj/obj/env_city_layout/instances
obj/obj/env_city_layout/instances/largeTower
obj/obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24
obj/obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24/unreal
obj/obj
obj/obj/env_city_layout
obj/obj/env_city_layout/instances
obj/obj/env_city_layout/instances/flatSlabs
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4/unreal
obj/obj
obj/obj/env_city_layout
obj/obj/env_city_layout/instances
obj/obj/env_city_layout/instances/flatSlabs
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5
obj/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5/unreal
So I did the next thing that would make sense which is us if statements. treat the first index differently from the next.. but this seems to delete all indexes of the rest of the paths as well..
FullPath = ['/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal', '/obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6/unreal',
'/obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24/unreal','/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4/unreal',
'/obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5/unreal']
for path in FullPath:
#print path
parent, name = path.split("/", 1)
for part in path:
pathSplit = path.split ("/")
#print pathSplit
indexToRemove = [0]
for index in sorted(indexToRemove, reverse=True):
del pathSplit[index]
#print pathSplit
for index in range (len(pathSplit)):
#print pathSplit[index]
if index == 0:
pathNew = str(pathSplit[0]) + "/" + str(pathSplit[1])
indexToRemove = [0, 1]
for index in sorted(indexToRemove, reverse=True):
del pathSplit[index]
pathSplit.insert(0, pathNew)
if index > 0:
pathNew = str(pathSplit[0]) + "/" + str(pathSplit[index])
del pathSplit[0]
pathSplit.insert(0, pathNew)
print pathNew
unfortunately this spits out only 1 of the paths. it's exactly what I want to see in terms of structure however, It also gives me a "list index out of range" error.
>>> obj/env_city_layout
obj/env_city_layout/instances
obj/env_city_layout/instances/flatSlabs
obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2
obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal
What am I missing? ( maybe having to take care of a kid while coding this is clouding me. But yeah I just can't see it at the moment.
The second result is exactly what I want to see, but for all the paths provided... and then the last thing is for it to create the accumulated list of all of these paths that would then work with your previous script.
so in the end I am hoping for this script to create something like..
FullPath = ['obj/env_city_layout',
'obj/env_city_layout/instances',
'obj/env_city_layout/instances/flatSlabs',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl2/unreal',
'obj/obj/env_city_layout',
'obj/env_city_layout/instances',
'obj/env_city_layout/instances/largeTower',
'obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6',
'obj/env_city_layout/instances/largeTower/prp_largeTower_mdl6/unreal',
'obj/obj/env_city_layout',
'obj/env_city_layout/instances',
'obj/env_city_layout/instances/largeTower',
'obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24',
'obj/env_city_layout/instances/largeTower/prp_TwoTowersYAAA_md24/unreal',
'obj/env_city_layout',
'obj/env_city_layout/instances',
'obj/env_city_layout/instances/flatSlabs',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl4/unreal',
'obj/env_city_layout',
'obj/env_city_layout/instances',
'obj/env_city_layout/instances/flatSlabs',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5',
'obj/env_city_layout/instances/flatSlabs/prp_flatSlab_mdl5/unreal']
Cheers. and thanks again for helping
-mk